<template>
  <el-dialog :append-to-body="true" :visible.sync="dialog" title="修改会员类型" width="600px">
    <el-form ref="form" :model="form" size="small" label-width="120px">
      <el-form-item label="设置标签:" prop="member_type">
        <el-radio-group v-model="form.member_type">
          <el-radio v-for="item in rolestypes" :key="item.key" :label="item.key" :disabled="item.key <= type">{{ item.value }}</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button :loading="loading" type="primary" @click="cancel">取消</el-button>
      <el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { updateMemberType } from '@/api/mall/customer'
import COMMEN from '@/utils/commen'
export default {
  components: { },
  data() {
    return {
      rolestypes: COMMEN.TYPE_SELECT_ROLE,
      loading: false,
      dialog: false,
      type: 0,
      form: {
        member_type: '',
        ids: []
      },
      rules: {
      }
    }
  },
  methods: {
    cancel() {
      this.resetForm()
    },
    doSubmit() {
      this.loading = true
      updateMemberType(this.form).then(() => {
        this.resetForm()
        this.$notify({
          title: '修改成功',
          type: 'success',
          duration: 2500
        })
        this.loading = false
        this.$parent.init()
      }).catch(() => {
        this.loading = false
      })
    },
    resetForm() {
      this.dialog = false
      this.$refs['form'].resetFields()
      this.form = {
        member_type: 0
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }

</style>
